#include "TestClassInitializer.h"


std::map <std::string, TestClassInitializer::runtimeCreateFunType*>& TestClassInitializer::_getRegTestClasses()
{
    static std::map <std::string, TestClassInitializer::runtimeCreateFunType*> _regTestClasses;
    return _regTestClasses;
}


TestClassInitializer::TestClassInitializer(std::string className, runtimeCreateFunType *fun)
{
    std::map <std::string, runtimeCreateFunType*> &regTestClasses = _getRegTestClasses();
    if (regTestClasses.count(className) != 0)
        printf("Error [%s] exist already\n", className.c_str());
    else
        regTestClasses[className] = fun;
}


TestCase* TestClassInitializer::createTestCase(std::string className)
{
    std::map <std::string, runtimeCreateFunType*> &regTestClasses = _getRegTestClasses();
    if (regTestClasses.count(className) == 0)
        return NULL;
    return regTestClasses[className]();
}


